cmake_minimum_required(VERSION 2.8)
project(glut)
file(GLOB lib_srcs *.c)
list(REMOVE_ITEM lib_srcs
    "${CMAKE_CURRENT_SOURCE_DIR}/capturexfont.c"
    "${CMAKE_CURRENT_SOURCE_DIR}/glut_menu.c"
    "${CMAKE_CURRENT_SOURCE_DIR}/glut_menu2.c"
    "${CMAKE_CURRENT_SOURCE_DIR}/layerutil.c")
set(lib_hdrs GL/glut.h)
set(CMAKE_DEBUG_POSTFIX "D")
include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR})
if(MSVC)
  list(APPEND lib_srcs ${PROJECT_NAME}.rc ${PROJECT_NAME}.def ${PROJECT_NAME}.ico)
endif()
add_library(${PROJECT_NAME} SHARED ${lib_hdrs} ${lib_srcs})
target_link_libraries(${PROJECT_NAME} winmm glu32 opengl32)
install(DIRECTORY GL DESTINATION include)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}-config.cmake)

if(BUILD_STATIC)
  add_library(${PROJECT_NAME}S STATIC ${lib_hdrs} ${lib_srcs})
  install(TARGETS ${PROJECT_NAME}S EXPORT ${PROJECT_NAME}S-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
  install(EXPORT ${PROJECT_NAME}S-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}S-config.cmake)
endif()
